package com.krahets88.hashtable;

import java.util.HashMap;

public class Question205 {
}

class Solution {
    public boolean isIsomorphic(String s, String t) {
        HashMap<Character, Character> dict = new HashMap<>(), dict1 = new HashMap<>();
        if (s.length() != t.length()) {
            return false;
        }
        for (int i = 0; i < s.length(); i++) {
            if ((dict.containsKey(s.charAt(i)) && (t.charAt(i) != dict.get(s.charAt(i)))) || dict1.containsKey(t.charAt(i)) && (s.charAt(i) != dict1.get(t.charAt(i)))){
                return false;
            } else {
                dict.put(s.charAt(i), t.charAt(i));
                dict1.put(t.charAt(i), s.charAt(i));
            }
        } return true;
    }
}